package org.example.node;

/**
 * @author liyishan
 * @date 2024/10/14 11:18
 * @apiNote
 */

public class BModdEvenList {

    public ListNode oddEvenList(ListNode head) {
        if(head == null){
            return head;
        }
        ListNode odd = head;
        ListNode even = head.next;
        ListNode evenHead = even;
        while(even!= null && even.next!= null){
            odd.next = even.next;
            odd = odd.next;
            even.next = odd.next;
            even= even.next;
        }
        odd.next = evenHead;
        return head;
    }
}
